package com.starry.module.system.core.oauth2.mapper;

import com.starry.db.core.mapper.BaseMapperX;
import com.starry.db.core.query.LambdaQueryWrapperX;
import com.starry.module.system.core.oauth2.entity.Oauth2ThirdAccount;
import org.apache.ibatis.annotations.Mapper;

/**
 * 第三方用户-数据库服务层
 *
 * @author xiaoke
 */
@Mapper
public interface Oauth2ThirdAccountMapper extends BaseMapperX<Oauth2ThirdAccount> {


    /**
     * 获取第三方用户信息查询
     *
     * @param openId openId
     * @return Oauth2ThirdAccount
     */
    default Oauth2ThirdAccount getByOpenIdAndType(String type, String openId) {
        return selectOne(new LambdaQueryWrapperX<Oauth2ThirdAccount>()
                .eq(Oauth2ThirdAccount::getType, type)
                .eq(Oauth2ThirdAccount::getOpenid, openId)
        );
    }
}

